<%@page import="entities.GoodsEntity"%>
<%@page import="entities.SellerEntity"%>
<%@page import="entities.TgoodsEntity"%>

<%@ page language="java"
	import="java.util.*,service.*,java.math.BigDecimal;"
	pageEncoding="UTF-8"%>
<%

	String userName = (String) session.getAttribute("userName");
%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="css/indexStyle.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.animation.easing.js"></script>
<script type="text/javascript" src="js/jquery.mousewheel.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript" src="js/lhgdialog.min.js"></script>
<script type="text/javascript" src="js/GlobalFunction.js"></script>


<title>网上外卖订餐系统</title>
<style type="text/css">
/*显示操作按钮*/
.site:hover .actions {
	display: block;
}
/*操作*/
.actions {
	display: none;
	top: 10px;
	left: 0px;
	z-index: 3;
	width: 100%;
	position: absolute;
}

.actions a {
	text-decoration: none;
	padding: 5px 10px;
	color: #555;
	background-color: #f5f5f5; /*浅灰*/
	border-radius: 3px;
}

.actions  a:hover {
	background-color: #7CDAEF;
	color: red;
}

/*评分*/
.score dl {
	display: inline;
}

.score dt {
	float: left;
	width: 22px;
	text-indent: -9999px;
	padding: 0px;
	background: url('images/star.png') no-repeat;
}

.score dt.on {
	background-position: 0 -28px;
}

.score span {
	float: left;
	margin-left: 3px;
	font-size: 13px;
	color: #0066ff;
}
/*商品名*/
span.goodsName {
	font-size: 16px;
}
/*销售量*/
span.saleCount {
	color: red;
	font-size: 14px;
}

span.sale {
	color: #bbbbbb;
	font-size: 14px;
}
</style>
</head>
<body>
	<!-- 头部 -->
	<jsp:include page="header.jsp"></jsp:include>
	<!-- 头部 -->
	<div style="display:none;" id="userName"><%=userName%></div>
	<div style="height: 10px;"></div>
	<div id="place">
		<!--开始第一屏-->
		<div id="name1"></div>
		<div id="wrapper1">
			<%
				List<SellerEntity> sellerList = SellerService.getHotSeller();
				int i;
				for (i = 0; i < sellerList.size(); i++) {
					if (!sellerList.isEmpty()) {
			%>
			<div class="site" id="thumb1-<%=i + 1%>">
				<a href="menu.jsp?sellerId=<%=sellerList.get(i).getId()%>"> <img width="100%" height="100%"
					src="<%=sellerList.get(i).getLogoURL()%>"
					title="<%=sellerList.get(i).getName()%>"
					alt="<%=sellerList.get(i).getName()%>" /> </a>
			</div>
			<%
				}
			}
			%>
			<div class="site" id="thumb1-<%=i + 1%>">
				<a href="seller.jsp"> <img width="100%" height="100%"
					src="images/more.png" alt="更多" /> </a>
			</div>
		</div>
		<!--结束第一屏 end wrapper1 -->

		<!--开始第二屏 start wrapper2-->
		<div id="button1to2"></div>
		<div id="button2to1"></div>
		<div id="name2"></div>
		<div id="wrapper2">
			<%
				List<GoodsEntity> menuList = GoodsService.getHotGoods();
				for (i = 0; i < menuList.size(); i++) {
					if (!menuList.isEmpty()) {
			%>
			<div class="site" id="thumb2-<%=i + 1%>">
				<a href="goodsDetail.jsp?goodsId=<%=menuList.get(i).getId()%>"> <img class="goodsImg"
					id="goods_image-<%=i + 1%>" width="100%"
					src="<%=menuList.get(i).getImageUrl()%>"
					alt="<%=menuList.get(i).getName()%>"
					title="<%=menuList.get(i).getName()%>" /> </a>
				<div class="score">
					<dl>
						<%
							int score = new BigDecimal(menuList.get(i).getRank() + "")
										.setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
							for (int j = 1; j <= score; j++) {
						%>
						<dt class="on"><%=j%></dt>
						<%
							}
							for (int j = 1; j <= 5 - score; j++) {
						%>
						<dt><%=(5 - score)%></dt>
						<%
							}
						%>
					</dl>
					<span><%=menuList.get(i).getRank()%></span>
					<div style="float: right;margin-right: 10px;">
						<span class="goodsName"><%=menuList.get(i).getName()%></span><span class="sale">(销售:</span><span class="saleCount"><%=menuList.get(i).getSaleCount()%>)</span>
					</div>
				</div>
				<!-- 购买、收藏、评论 -->
				<div align="center" class="actions">
					<a class="buy" id="<%=menuList.get(i).getId()%>"
						onclick="readyBuy(<%=menuList.get(i).getId()%>);"
						href="javascript:void(0);return false;">加入购物车</a> <a
						class="collect"  onclick="readyCollect(<%=menuList.get(i).getId()%>);" href="javascript:void(0);">收藏</a>
				</div>
			</div>
			<%
				}
					}
			%>
			<form action="<%=basePath %>search.jsp" method="post">
				<input id="searchKey" type="text" name="searchKey" value="" />
				<button id="searchBt" type="submit"></button>
			</form>
		</div>
		<!--结束第二屏 end wrapper2 -->

		<div id="button2to3"></div>
		<div id="button3to2"></div>
		<div id="name3"></div>
		<div id="wrapper3">
		<%
				List<TgoodsEntity> tgList = TgoodsService.getHotTgoods();
				for (i = 0; i < tgList.size(); i++) {
					if (!tgList.isEmpty()) {
			%>
			
			<div class="site" id="thumb2-<%=i + 1%>">
				<a href="tgdetail.jsp?tgoodsId=<%=tgList.get(i).getTgId()%>"> <img class="goodsImg"
					id="goods_image-<%=i + 1%>" width="100%"
					title="<%=tgList.get(i).getTgName()%>"
					src="<%=tgList.get(i).getTgImage()%>"
					alt="<%=tgList.get(i).getTgName()%>" /> </a>
				<div class="score">
					
					<span><%=tgList.get(i).getSellerName()%></span>
					<div style="float: right;margin-right: 10px;">
						<span class="goodsName"><%=tgList.get(i).getTgName()%></span><span class="saleCount">￥<%=tgList.get(i).getTgPrice()%></span><span class="sale">(销售:</span><span class="saleCount"><%=tgList.get(i).getTgSaCou()%>)</span>
					</div>
				</div>
				<!-- 购买、收藏、评论 -->
				<div align="center" class="actions">
					<a class="buy" id="<%=menuList.get(i).getId()%>"
						onclick="readyBuy(<%=menuList.get(i).getId()%>);"
						href="javascript:void(0);return false;">加入购物车</a>
				</div>
			</div>
			<%
				}
					}
			%>
			<div class="site" id="thumb2-<%=i + 1%>">
				<a href="tuangou.jsp"> <img width="100%" height="100%"
					src="images/more.png" alt="更多" /> </a>
			</div>
		</div>
		<!--结束第三屏 end wrapper3 -->
	</div>
	<!-- end place -->
</body>

<!-- JiaThis 分享到 Button BEGIN -->
<script type="text/javascript"
	src="http://v1.jiathis.com/code/jiathis_r.js?move=0&amp;uid=1514104"
	charset="utf-8"></script>
<!-- JiaThis 分享到 Button END -->
<script type="text/javascript">
	//$(document).ready(
	function readyBuy(goodsId){
		var userName = $("#userName").html().trim();
		//alert(userName+"==="+goodsId);
		buy(userName,goodsId);
	//		return false;
	};
	
	//收藏商品按钮
	function readyCollect(goodsId){
		var userName = $("#userName").html().trim();
		collect(userName,goodsId);
	};
</script>
</html>
